package com.cgy.config;


import com.cgy.constant.FaceConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TopicExchange配置类
 *
 * @author think
 * @since 2023/11/3
 */
@Configuration
public class TopicExchangeConfig {

    @Bean("faceExchangeBean")
    public DirectExchange getDirectExchangeTx() {
        return new DirectExchange(FaceConstant.FTP_TOPIC_EXCHANGE_NAME, true, false);
    }

    @Bean("faceQueueBean")
    public Queue getQueueTx() {
        return new Queue(FaceConstant.FTP_TOPIC_QUEUE_NAME, false, false, false);
    }

    @Bean
    public Binding getDirectExchangeQueueTx(@Qualifier(value = "faceExchangeBean") DirectExchange getDirectExchangeTx,
                                            @Qualifier(value = "faceQueueBean") Queue getQueueTx) {
        return BindingBuilder.bind(getQueueTx).to(getDirectExchangeTx).with(FaceConstant.FTP_TOPIC_ROUT_KEY_NAME);
    }

}
